package com.moweilin.folded_binding.components;

import com.moweilin.folded_binding.components.buttons.BuildPane;
import com.moweilin.folded_binding.components.buttons.CenterPane;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;

/**
 * Created by moweilin on 2017/2/5.
 */
public class MainPage extends VBox {
    private Node buildPane;
    private BorderPane centerContainer;
    public MainPage() {
        getChildren().add(new TopBar());
        getChildren().add(buildCenter());
//        setRight(new BuildPane());
    }
    protected Node buildCenter(){
        StackPane stackPane = new StackPane();
        stackPane.setStyle("-fx-background-color:red");
        stackPane.getChildren().add(buildContent());
        buildRightTopBar(stackPane);
        return stackPane;
    }
    protected Node buildContent(){
        CenterPane centerPane = new CenterPane();
        return centerPane;
//        return new VBox();
    }
    protected void buildRightTopBar(StackPane parent){
        Button button = new Button();
        button.setOnAction(this::handleToggleBuildPaneButton);
        button.setText("展开");
        parent.getChildren().add(button);
        StackPane.setAlignment(button,Pos.TOP_RIGHT);
    }
    protected void  handleToggleBuildPaneButton(ActionEvent event) {
        if(buildPane == null){
            buildPane = new BuildPane();
        }
//        if(getRight() == null){
//            setRight(buildPane);
//        }else {
//            setRight(null);
//        }
    }
}
